package com.hl.card.credit.creditcard;

import com.hl.card.credit.domain.InitailFormDTO;
import com.hl.card.credit.utill.HttpClientTool;
import com.hl.card.credit.utill.PingAnTool;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import static com.hl.card.credit.utill.PingAnTool.getUrlReal;
import static com.hl.card.credit.utill.StatusTool.getSign4;

/**
 * 平安真实环境
 *
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class PingAnReal {

    @Test
    public void demoRequest() {
        String url="";
        InitailFormDTO initDTO=new InitailFormDTO();
        initDTO.setPartnerSeqId("m180320106300000201804191255555271111");
        initDTO.setScc(PingAnTool.scc);
        initDTO.setTemplateNo("s180419Oot");
        initDTO.setMt("123456789");
        initDTO.setCcp("1a2a3a9");
        initDTO.setVersionNo("R10310");
        initDTO.setOnlineSQFlag("N");
        initDTO.setCardCatenaNo("01a02a04");
        initDTO.setChannel("WXHZF");
        System.out.println("需要加密的入参:"+initDTO);
        url=getUrlReal(initDTO);
        System.out.println( "最终生成测试环境url：" + url);
    }


    @Test
    public void queryStatus() {
        String curl = "https://c.pingan.com/ca/scc/merchant/order/getStatus";
        Map<String,String[]> map = new TreeMap();
        map.put("merchant_key",new String[]{"a6c4cc11037bd074536a394f25584d77"});
        map.put("order_id", new String[]{"m180301729420180302104130012345678901"});
        map.put("timestamp",new String[]{"1520305365933"});
        String sign=getSign4(map);
        System.out.println(sign);
        Map param=new HashMap();
        param.put("order_id",map.get("order_id")[0]);
        param.put("timestamp",map.get("timestamp")[0]);
        param.put("sign",sign);
        HttpClientTool.createSSLClientDefault();
        String res=HttpClientTool.doGetSSL(curl,param);
        System.out.println(res);
    }

}
